<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=640,target-densitydpi=320,user-scalable=no">
<title>无标题文档</title>
<script type="text/javascript" src="<?=base_url()?>public/js/jq.1.12.4.js"></script>
<link rel="stylesheet" type="text/css" href="<?=base_url()?>public/css/m.css"/>
</head>
<body>
<div class="topp">得道天合</div>
<div class="w640">
<div  class="zhmm">
<div class="changeWay" style="text-align: center;">
    <label style=" font-size: 18px;margin-right: 20px;">
        <input type="radio" class="active" name="type" value="pwd" style="width: 20px;margin-right:10px;height: 20px;transform: translateY(3px);" checked>找回登录密码
    </label>
    <label style=" font-size: 18px;margin-right: 20px;">
        <input type="radio" name="type" value="spwd" style="width: 20px;margin-right:10px;height: 20px;transform: translateY(3px);">找回二级密码
    </label>
</div>
<?php echo form_open('mobile/forget/update_pwd',array('id'=>'myform')); ?>
         <table class="biao">
	     <tr>
		    <td valign="top" class="w140h">修改登录密码</td>
           <td><input id="new_pwd" name="new_pwd" type="password" class="input1"/>
		   <div class="clear"></div>
           <p class="beizhu beizhu111">&nbsp;</p></td>
		 </tr>
		 <tr>
		    <td></td>
           <td></td>
		 </tr>
		 <tr>
		    <td valign="top" class="w140h">验证手机号</td>
	        <td><input id="mobile" name="mobile" type="html" class="i280"/><input id="send_yzm" type="button" class="i110" value="获取验证码" style='margin-left:-40px;' /><div class="clear"></div>
             <p class="beizhu beizhu222">&nbsp;</p></td>
		 </tr>
		 <tr>
		    <td valign="top" class="w140h">验证码</td>
	        <td>
				<input id="yzm" name="yzm" type="html" class="input1"/>
				<p class="beizhu beizhu333">&nbsp;</p></td>
			</td>
		 </tr>
		 
		 <tr>
		    <td colspan="2" >
		        <div class="inp360"><input id="zhaohui" type="button" name="Submit2" value="确认提交" class="inputt" /></div></td>
         </tr>
	  </table>
</form>
</div>
</div>
<script type="text/javascript">
$(function(){
	//二级密码功能
	   $(".changeWay>label").each(function(){
        $(this).click(function(){
            $(this).addClass("active").siblings().removeClass("active");
            if($(this).children("input").val()==="pwd"){
                $("#myform tr:first-child>td:first-child").html("修改登录密码");
            }else{
                $("#myform tr:first-child>td:first-child").html("修改二级密码");
            }
        });
    });
	var phon = /1[3578][0-9]\d{4,8}/;
	
  $('#zhaohui').click(function(event) {

    //密码
	if($('#new_pwd').val() == ''){
		$('.beizhu111').html('请输入新密码');
		return false;
	}else{
		$('.beizhu111').html('');
	}
    if($('#new_pwd').val().length < 6){
		$('.beizhu111').html('密码长度不得少于6位');
        return false;
	}else{
		$('.beizhu111').html('');
	}
    if($('#new_pwd').val().length > 20){
		$('.beizhu111').html('密码长度不得大于20位');
        return false;
	}else{
		$('.beizhu111').html('');
	}
	
    //手机号
    if(!phon.test($('#mobile').val())){
		//$('.js-tishi').css('display','block');
		$('.beizhu222').html('请输入正确的手机号');
		return false;
    }else{
		$('.beizhu222').html('');
	}
	//验证码
	if($('#yzm').val() == ''){
		$('.beizhu333').html('请输入验证码');
		return false;
	}else{
		$('.beizhu333').html('');
	}
    $('#myform').submit();
    
  });

  
		var InterValObj;//time
	   var count = 60;
	   var curCount;
	  
	  //通过短信接口向手机发送短信
	  $('#send_yzm').on('click',  function(event) {
	    var reg = /^\d{11}$/;
	    if(!reg.test($('#mobile').val())){
			$('.js-tishi').css('display','block');
		  $('.beizhu222').html('请输入正确的手机号');
	     // alert('请输入正确的手机号');
	      return false;
	    }
	    var mobile = $('#mobile').val();
	    var checkmobile = mobile.substring(0,2);

		if (checkmobile == '17') {
			$('.js-tishi').css('display','block');
		   $('.beizhu222').html('您的电话号码不符合');
			//alert("您的电话号码不符合");
			return false;
		}
	    curCount = count;
		$('#send_yzm').attr('disabled','true');
		$('#send_yzm').val(curCount+'秒内输入');
		InterValObj = setInterval(SetRemainTime,1000);
		
	    var url = '<?php echo site_url("mobile/reg/ajax_send_check_code") ?>';
	    $.post(url, {mobile: $('#mobile').val()}, function(d) {
	      if(d.err > 0){
			  $('.js-tishi').css('display','block');
	      //  alert('提交成功');
			$('.beizhu222').html('');
	        //$('#sms_code').val(d.code);
	      }else{
			$('.beizhu222').html(d.msg);
	      }
	    });

	  });
	  function SetRemainTime(){
			if(curCount == 0){
				clearInterval(InterValObj);
				$('#send_yzm').removeAttr('disabled');
				$('#send_yzm').val('发送验证码')
			}else{
				curCount--;
				//console.log(curCount)
				$('#send_yzm').val(curCount+'秒内输入');
			}
		}
})
</script>
</body>
</html>